package com.googlecode.jpocketmod.actions;

import java.util.List;
import java.util.Vector;
import javax.swing.AbstractAction;

/**
 *
 * @author David Sosby
 */
public abstract class ApplicationAction extends AbstractAction  {
	private List<ApplicationEventListener> listeners = new Vector<ApplicationEventListener>();
	
	public void addApplicationEventListener(ApplicationEventListener listener)  {
		listeners.add(listener);
    }
	
	public void fireApplicationExitEvent()  {
		ApplicationExitingEvent exitEvent = new ApplicationExitingEvent();
		for ( ApplicationEventListener listener : listeners )  {
			listener.applicationExiting(exitEvent);
		}
	}
	
	public void fireTemplateLoadedEvent()  {
		TemplateLoadingEvent event = new TemplateLoadingEvent();
		for ( ApplicationEventListener listener : listeners )  {
			listener.templateLoading(event);
		}
	}
	
	public void fireThisAction()  {
		runAction();
    }
    
    protected abstract void runAction();
}
